be a little smarter about when to redirect stderr

The fix in 0e34978 doesn't work in the most recent versions of
IPython.
Merge pull request #4 from dougalsutherland/fix-stderr

be a little smarter about when to redirect stderr