Split core functionality and main function so that `setup.py` can import `__version__`

Installation from PyPI was failing because inside `setup.py` the module `pjson` was imported (in order to pass `__version__` to `setup()`), and the library `xmlformatter` wasn't yet installed. So the installation failed with an `ImportError`.

This pull request fixes that, by splitting the core functionality and the main function.