RFCT Explicitly set warning handler

This does the same as the default handler.

A minor benefit of this structure is that we now reset the old error
handler when we are done. Previously, imread would set the error handler
and forget about it.