Added urlencode to import.
Fixed problems reported by flake8.