Removed decoding and added check for image types