Validate that the image is well-formed. Fixes #1