Use buffered STDOUT writer for better performance

Instaed of printing directly to STDOUT, this commit adds a 512
byte buffer that is flushed to STDOUT as needed.