made the image upload more robust