Use subprocess.DEVNULL when possible

Also, this change causes to open os.devnull at most once, thus fixes #353