flush stdio and display before pyout, fixes #44