Fix up little I/O problems (encoding, flushing).