Read stdout and stderr safely but inefficiently

This change is designed to cope with streams that are closed
concurrently. The Java InputStreamReader seems to have a race
condition where it can't handle a stream being closed while it is
reading.