Writes a given data to a file located at the given path.

def write(path, data, binary=False):
    """ Writes a given data to a file located at the given path. """
    mode = "w"
    if binary:
        mode = "wb"
    with open(path, mode) as f:
        f.write(data)
    f.close()