tools: mkimage: Call fclose in error path