Optimal buffer size for output stream
It depends on a lot of factors, there's no universally "optimal" size. 512kB is probably good enough.

If you want, you can always benchmark it for various buffer sizes: this will let you know what the best option is for your computer and OS.