Convert the specified image instance to RGB mode.


    @param image: a Python Library Image (PIL) instance to convert its
        pixel format to RGB, discarding the alpha channel.

    @param fill_color: color to be used to fill transparent pixels when
        discaring the alpha channel.  By default, the white color.


    @return: a Python Library Image instance with pixel format of RGB.

def convert_image_to_rgb_mode(image, fill_color=(255, 255, 255)):
    """
    Convert the specified image instance to RGB mode.


    @param image: a Python Library Image (PIL) instance to convert its
        pixel format to RGB, discarding the alpha channel.

    @param fill_color: color to be used to fill transparent pixels when
        discaring the alpha channel.  By default, the white color.


    @return: a Python Library Image instance with pixel format of RGB.
    """
    if image.mode not in ('RGBA', 'LA'):
        return image

    # In most cases simply discarding the alpha channel will give
    # undesirable result, because transparent pixels also have some
    # unpredictable colors. It is much better to fill transparent pixels
    # with a specified color.
    background_image = Image.new(image.mode[:-1], image.size, fill_color)
    background_image.paste(image, image.split()[-1])
    return background_image