Make `upload_image` take a path instead of file.

This fixes problems coming from opening the image file in incorrect mode.