Add spec for Marshal.dump with an IO with encoding
Call IO#binmode if it's defined when marshalling

Fixes #2583