'Wrapper to Matplotlib\'s :meth:`~matplotlib.axes.Axes.imshow`.
If an RGB image is passed as a PIL object, it will be flipped
vertically and ``origin`` will be set to ``lower``, since WCS
transformations - like FITS files - assume that the origin is the lower
left pixel of the image (whereas RGB images have the origin in the top
left).
All arguments are passed to :meth:`~matplotlib.axes.Axes.imshow`.'

def imshow(self, X, *args, **kwargs):

    origin = kwargs.get('origin', None)
    if (origin == 'upper'):
        raise ValueError("Cannot    use    images    with    origin='upper'    in    WCSAxes.")
    try:
        from PIL.Image import Image, FLIP_TOP_BOTTOM
    except ImportError:
        pass
    else:
        if (isinstance(X, Image) or hasattr(X, 'getpixel')):
            X = X.transpose(FLIP_TOP_BOTTOM)
            kwargs['origin'] = 'lower'
    return super(WCSAxes, self).imshow(X, *args, **kwargs)
