Initialize Pretty formatter with output stream when autoformatting - fix issue #597

Test and fix for nil output stream when using --autoformat option.