fixes to detecting image type of NSData