This patch checks if the image is nil; if so, it redirects to the image index page and
throws an error.
A simple way to duplicate this bug is to browse to any particular image, and then add a
random letter to the end of the URL (i.e., change the image id)
Mainn