def unique_color_from_identifier(identifier):
    """Return unique color as RGB tuple.

    Useful for creating PNG images where each color is used as an identifier.

    Raises TypeError if the identifier is not an integer.

    Raises ValueError if the identifier is not in the range 0 to 16777215
    inclusive.

    :param identifier: positive integer in range from 0 to 16777215 inclusive
    :raises: TypeError, ValueError
    :returns: RGB tuple
    """
    if not isinstance(identifier, int):
        raise(TypeError("Identifier is not an integer {}".format(identifier)))
    if identifier < 0:
        raise(ValueError("Negative identifier not allowed"))
    if identifier >= 256*256*256:
        raise(ValueError("Identifier {} >= {}".format(identifier,
                                                      256*256*256)))
    blue = identifier % 256
    green = (identifier // 256) % 256
    red = (identifier // (256*256)) % 256
    return (red, green, blue)