def unpack_bits(x):
    """convert byte x into a list of bools corresponding to bits"""
    bools = []
    while x:
        for i in range(8):
            bools.append(bool(x&1))
            x >>= 1
    return bools