further work on image uploading.  lots of refactoring/clean up to do