write entity header as well