remove extra flush and close calls; fix java8 bug

java8 changed the behavior of dos.close() to not swallow the
io exception generated by some streams when dos.close() calls
flush after the underlying stream has already been explicitly
closed. that may be technically considered a bug in the stl,
but no need to generate exceptions for no reason anyway.