Fixes handling of corrupted files

Fixes failure on invalid filter type.
Adds error handling for IHDR and PLTE parsing.
formatting: spaces to tabs
Merge pull request #17 from nwin/master

Fixes handling of corrupted files