Fixed runtime error where image formats were not recognized