refactoring upload function

* removing subprocess wait in favor of communicate
* adding a local variable for imagefile
* restructuring upload logic to fail before updating the image list