correct image deletion post url

the POST action URL used on the image deletion form was incorrect
which meant images could not be deleted. Fix this by adding an image url
generating function rather than coding them by hand in the template.

Fixes #407 and #412