def valid_map(file_name):
    """
    Checks if the magic numbers of a given file correspond to a
    Warcraft III map file
    """
    with open(file_name, "rb") as f:
        map_name_bytes = f.read(4)

    try:
        map_name_bytes = str(map_name_bytes.decode('utf-8'))
    except UnicodeDecodeError:
        return False

    if map_name_bytes == "HM3W":
        return True

    return False