Fix error handling in UploadImage