Add function to check for image type.

Some servers do not have exif_imagetype available. So I added a work around.