Create path to filename and saves binary data

def write_binary(filename, data):
    """Create path to filename and saves binary data"""
    dir = os.path.dirname(filename)
    if not os.path.exists(dir):
        os.makedirs(dir)
    with open(filename, 'wb') as f:
        f.write(data)