Fixed an error with invalid image ID

Fixed an error where an invalid image ID returned server 500.