Improve 'checkImageFormat' to differentiate between non-image formats versus empty files.