Updated for Python 3

Removed declaration of text string as unicode (default behaviour in Python 3).
Whitespace regex now compiled before iterating through document.