Use file object's .closed instead of _istream_open
Fix issue #31 by catching UnicodeDecodeError as well
Fix an unit test fails in python 2.5 for issue #31