Clean up local variable usage - upload_image()

Cleans up the rather coplex upload_image() function

Change-Id: Ie1ef200b905dd5d17ef887390d620817208f2bf5
Merge "Clean up local variable usage - upload_image()"