Flatten serialization.

Fix a bug where InputStream.read() doesn't returns without reading the
full content of the string.