factor out write buffer code so any module and libk users can call it; update documentation to match; add kssz string length function