urllib: fix urllib handeling in python 2 and 3 closes #1286