make 'upload_image' function more flexible