improve performance by buffering output stream