fixing and cleaning up the image upload