add image put endpoint to replace images over the API

PUT /:collection/:id/image/:image_id replaces the image with image_id.

Factors out the code common to the PUT and POST requests into functions
to reduce duplication.