fix #929 by validating image magic number
Merge pull request #1005 from chrox/fix_929

fix #929 by validating image magic number