FIX: Can't capture console output on Windows
FIX: flush all stream to avoid disordered output
Merge pull request #760 from qtxie/win-console-redirect

FIX: Can't capture console output on Windows