append2simg: write to temporary file

append2simg causes libsparse to write mmapped data from a file
back to that same file.  On btrfs, this sometimes causes a page
of zeroes to be written instead of the file data.  Work around
the issue by writing the output to a temporary file and then
renaming it over the original file.

Change-Id: Ia194b6ba0ddb8548747b63292b523756f544706a
2 files changed