Buffer the writing of frames.

Previously each written frame went in its own network packet.

Now we buffer until the frame writer has nothing else to write, at
which point it flushes and discards its write buffers, to minimize
the memory usage of idle connections.