def write(path, data, binary=False):
    """ Write data to a file located in a given path. If binary is true will
    open the file with the binary flag and data should be bytes instead of
    string.
    :param str path: Path where the file is located
    :param str|bytes data: Data to be writen in the file. If binary is true
    data must be in bytes instead of string.
    :param bool binary: If true will read the file with the binary flag
    """
    mode = 'w'
    if binary:
        mode = 'wb'
    with open(path, mode) as f:
        f.write(data)
