TST: Make sure files are removed in test_graphics
plt.savefig() appends an extension by default, which messes up ensure_clean().
Added option to ensure_clean() to just return file-like.

Closes #5347.
