based on https://pypi.python.org/pypi/XMLLayout, add support for python3