Updated to check image mimetype