More robust url decoding function