Use StringIO.write instead of print

- Previous print_function implementation didn't work
- Added StringIO to utils.compat
- Added a small unit tests to make sure str(sim.signals) works