If outputfile and logfile need to be 'wb', all the calls to outputfile.write elsewhere need updated to encode the string to bytes.
Alternatively, outputfile and log file can be opened as w, as done in this change. No buffering mode is only available for wb, so use 1 to get line buffering.
The urllib change is to account for python2 and python3 having urlopen in different modules.
If outputfile and logfile need to be 'wb', all the calls to outputfile.write elsewhere need updated to encode the string to bytes.
Alternatively, outputfile and log file can be opened as w, as done in this change. No buffering mode is only available for wb, so use 1 to get line buffering.
The urllib change is to account for python2 and python3 having urlopen in different modules.