MODE-2221 Moved the SelfClosingInputStream to the common package and changed it so that it only wraps (and closes) and InputStream.

Refactored the binary value classes to make sure any stream returned from a binary value is wrapped into a self closing stream.