Don't clobber user-given IOs and file descriptors

Make our own copies of file descriptors we get from users using IO#dup instead
of clobbering (closing!) them.