def _pil_image_to_bytes(p_img):
    """
    Get the component bytes from the given PIL Image.
    In recent version of PIL, the tobytes function is the correct thing to
    call, but some older versions of PIL do not have this function.
    :param p_img: PIL Image to get the bytes from.
    :type p_img: PIL.Image.Image
    :returns: Byte string.
    :rtype: bytes
    """
    if hasattr(p_img, 'tobytes'):
        return p_img.tobytes()
    else:
        # Older version of the function.
        return p_img.tostring()