flush output before showing tracebacks

closes #3700