def bytes2bin(bites, sz=8):
    """Accepts a string of ``bytes`` (chars) and returns an array of bits
    representing the bytes in big endian byte order. An optional max ``sz`` for
    each byte (default 8 bits/byte) which can  be used to mask out higher
    bits."""
    if sz < 1 or sz > 8:
        raise ValueError(f'Invalid sz value: {sz}')
    retval = []
    for b in [bytes([b]) for b in bites]:
        bits = []
        b = ord(b)
        while b > 0:
            bits.append(b & 1)
            b >>= 1
        if len(bits) < sz:
            bits.extend([0] * (sz - len(bits)))
        elif len(bits) > sz:
            bits = bits[:sz]
        bits.reverse()
        retval.extend(bits)
    return retval
