download_file helper function now decodes unicode on the fly