Fix bug with TypeError: 'str' does not support the buffer interface

Bug occurred when behind a corporate proxy,
confirmed on Windows XP, Windows 7, OS X 1.8.2

Credit goes to @holjan for the code