rustc: buffer the output writer for -Z ast-json[-noexpand].

rustc: buffer the output writer for -Z ast-json[-noexpand].

This takes the time for `rustc libstd/lib.rs -Z ast-json-noexpand > file.json` from 9.0s to 3.5s (~0.5s spent parsing etc.) and `-Z ast-json` from 11s to 5s (~1.5s spent parsing and expanding).