Fixed buffer concatenation inefficiency.

Instead of concatenating the buffers as you process each entry, collect the buffers in an array and concatenate them all at once at the end.

This improved a 7MB write process from ~6 seconds to <0.5 seconds.