ported #writeHeadBytes to native parser