fixes for writing null bytes and wip footer writing