def _lines_to_dict(lines):
    md = {}
    errors = []

    for line in lines:
        # Skip a line if there is invalid value.
        try:
            line = line.decode("utf-8")
        except UnicodeDecodeError as e:
            errors.append("Invalid line '{}': {}".format(line, e))
            continue

        if line.startswith("EOF"):
            break
        if '=' not in line:
            continue

        key, value = line.split('=', 1)
        md[key.strip()] = value.strip()

    return md, errors