add _toJson function in utils/__init__.py

PR for http://trac.buildbot.net/ticket/2659
This should probably drop the `_` and definitely get documented in `util.rst`