Try and protect against memory errors in EXIF reading

This is related to issue #21, but I can't reproduce the problem so it
remains mostly untested.