[MRG+1] Fixed ResourceWarnings from inside scikit-learn. Fixes #3410.

Remaining `ResourceWarning`s are due to a bug in Pillow (a PR is being created at the same time).
Same remark here: I think that the assert_array_... should not be in the with block.