add flushing of stdout to update on key event

Doing this as a demo for UC Berkeley Practical Neuroimaging class on
contributing to open source while getting your work done
Merge pull request #1848 from ivanov/keypress-stdout-flush

add flushing of stdout to update on key event