Add error-checking for map images.

Behaved really horribly before when reading invalid maps.