Copy write data, and batch writes.

Doing many tiny writes is very slow. By copying the data to be written into a
buffer, we can combine many writes into a single batch. In addition, we isolate
the data being written from any subsequent changes; for example, this means you
can now fill a reader and drain a writer in parallel without the reader
corrupting the writer’s data.