diff --git a/src/ImagemagickExecManager.php b/src/ImagemagickExecManager.php
index d24268e..e48bd32 100644
--- a/src/ImagemagickExecManager.php
+++ b/src/ImagemagickExecManager.php
@@ -290,14 +290,14 @@ class ImagemagickExecManager implements ImagemagickExecManagerInterface {
     Timer::start('imagemagick:runOsShell');
     if ($h = proc_open($command_line, $descriptors, $pipes, $this->appRoot)) {
       $output = '';
-      while (!feof($pipes[1])) {
-        $output .= fgets($pipes[1]);
-      }
-      $output = utf8_encode($output);
       $error = '';
-      while (!feof($pipes[2])) {
+      stream_set_blocking($pipes[1], FALSE);
+      stream_set_blocking($pipes[2], FALSE);
+      while (!feof($pipes[1]) && !feof($pipes[2])) {
+        $output .= fgets($pipes[1]);
         $error .= fgets($pipes[2]);
       }
+      $output = utf8_encode($output);
       $error = utf8_encode($error);
       fclose($pipes[0]);
       fclose($pipes[1]);
