code: def _to_pil_rgb_image(image):
      
      if image.mode == "RGB":
          return image
  
      from PIL import Image
  
      image.load()
      rgb_image = Image.new("RGB", image.size, (0x00, 0x00, 0x00))
      mask = None
  
      if image.mode == "RGBA":
          mask = image.split()[3]  # bands: R=0, G=1, B=2, 1=3
  
      rgb_image.paste(image, mask=mask)
  
      return rgb_image
docs: Returns an PIL Image converted to the RGB color space. If the image has
      an alpha channel (transparency), it will be overlaid on a black background.
  
      :param image: the PIL image to convert
  
      :returns: The input image if it was already in RGB mode, or a new RGB image
                if converted.
  
      :raises ImportError: PIL / Pillow cannot be imported.