stream: properly encode the write header length
stream: cosmetics