def _int12_to_int8(first, second=None):
    """Convert two 12-bit integers to three 8-bit integers for serialization.
    :param first: First 12-bit integer for conversion.
    :param second: Second 12-bit integer for conversion.
    :return: tuple of three 8-bit integers.
    """
    if first > 4095 or (second is not None and second > 4095):
        raise Exception("More than 12 bits")
    byte_1 = first >> 4
    byte_2_start = first << 4
    byte_2 = 0xff & byte_2_start
    if second is None:
        return byte_1, byte_2
    byte_2 |= second >> 8
    byte_3 = 0xff & second

    return byte_1, byte_2, byte_3