Specify ::IO for writemime.
Merge pull request #8352 from danluu/writemine_error_message

Specify ::IO for writemime