Merge "Refactor image writer"
am: 6004e14691

Change-Id: I6713a029794f5b267d16e6749743e334946e5777