Add functions to write output to a buffer.