improvements to io:fwrite