def getMagicComments(data, headersize=1024):
    """Given a byte string, get the first two lines.
    
    "Magic comments" appear in the first two lines of the file, and can
    indicate the encoding of the file or the major mode in which the file
    should be interpreted.
    """
    numbytes = len(data)
    if headersize > numbytes:
        headersize = numbytes
    header = data[0:headersize]
    lines = header.splitlines()
    return lines[0:2]
