BUG: close file-like objects returned by urlopen

Fix `ResourceWarning: unclosed file` on Python 3
Merge pull request #3924 from charris/backport-1.8-3923

backport-1.8-3923