Adapt to work in python2.6
Fix formatted_raw_ostream ownership error with the underlying stream.
Adapt to python 3.3
Fix writing to file-like obj in python3.3
Fix test