def METHOD_NAME(self):
    """Convert palette to bytes.
    .. warning:: This method is experimental.
    """
    if self.rawmode:
        raise ValueError("palette contains raw palette data")
    if isinstance(self.palette, bytes):
        return self.palette
    arr = array.array("B", self.palette)
    if hasattr(arr, "tobytes"):
        return arr.METHOD_NAME()
    return arr.tostring()