Make input streams buffered and close them after use

Several input streams were unbuffered and others were not closed
after use.
Merge pull request #114 from gbehrmann/fix/inputstream

Make input streams buffered and close them after use