Added urlencode function to enable downloading of files with special chars