A generator for unsynchronizing a byte iterable.

def gen_encode(data):
        "A generator for unsynchronizing a byte iterable."
        sync = False
        for b in data:
            if sync and (b == 0x00 or b & 0xE0):
                yield 0x00 # Insert sync char
            yield b
            sync = (b == 0xFF)
        if sync:
            yield 0x00