import math


def binary_data(string):
    """
    Takes a python string '1111111100000000' and converts it to a byte string
    b'\xff\x00'
    """
    padded_len = int(math.ceil(len(string) / 8) * 8)
    string = string.ljust(padded_len, '0')
    data = []

    while string:
        data.append(int(string[:8], 2))
        string = string[8:]

    return bytes(data)