I don't think the py2 check is needed. 

Seems to me this line should be
```
 if isinstance(stdout, six.binary_type)
```

This will basically say "if python 3 and a bytes object or if python 2 and str"