Factord out isImageFile method.