fix fatal on invalid image

fix fatal on invalid image
Merge pull request #2 from red-led/patch-2

Fix fatal on invalid image