Merge "Use PwriteFully and write image header last"
am: 68952cff97

* commit '68952cff9744b702f2fc67181c50ea76561c58e9':
  Use PwriteFully and write image header last