Added more robust image type detection in Files module