Fixed errors handling for python2.

Python2:

```python
import io, traceback

f = io.StringIO()
traceback.print_stack(file=f)


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/traceback.py", line 269, in print_stack
    print_list(extract_stack(f, limit), file)
  File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/traceback.py", line 23, in print_list
    '  File "%s", line %d, in %s' % (filename,lineno,name))
  File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/traceback.py", line 13, in _print
    file.write(str+terminator)
TypeError: unicode argument expected, got 'str'
```

io.StringIO accepts a unicode string, but python2 traceback module generates 8-bit strings. So solution is BytesIO for Python2.