algorithms: Add path support to rewrute_url.
algorithms: Add support for Internationalized Domain Names (IDN).
algorithms: Add query support to rewrite_url.
compat: Fix urlencode for Python < 3.0.

The urlencode function handles encoding in Python 3.x so our
compatibility layer should do so to.
algorithms: Conditionalize IDN support.