Fix iostream when used with nogil (#1368)

diff --git a/include/pybind11/iostream.h b/include/pybind11/iostream.h
index 9119270..72baef8 100644
--- a/include/pybind11/iostream.h
+++ b/include/pybind11/iostream.h
@@ -43,8 +43,11 @@
             // This subtraction cannot be negative, so dropping the sign
             str line(pbase(), static_cast<size_t>(pptr() - pbase()));
 
-            pywrite(line);
-            pyflush();
+            {
+                gil_scoped_acquire tmp;
+                pywrite(line);
+                pyflush();
+            }
 
             setp(pbase(), epptr());
         }