Fix image type handler to correctly handle extensions.

Unit tests would be nice, y'know.