def set_mode_of_pil(pil, mode):
    """
    This function sets the mode of the PIL object('pil') and returns this object.
    :param pil: PIL object representing an image
    :type pil: PIL.*
    :param mode: this param defines the type and depth of a pixel in the image
    (https://pillow.readthedocs.io/en/4.1.x/handbook/concepts.html#modes)
    :type mode: string - str
    :return: PIL object('pil') with the appropriate mode
    :rtype: PIL.Image.Image (https://pillow.readthedocs.io/en/3.1.x/reference/Image.html)
    """
    pil = pil.convert(mode)
    return pil