Add which.py and version.py

Revert back to use StringIO instead of cStringIO as the later is not a
class, which creates some type comparison issue.