Fix  python3.x compatibility for stable 2.0 branch

Change-Id: I958d02873e4ba76be72230365dff8e500fa31b3c
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/gen_cmd.py b/lib/gen_cmd.py
index 3b99fbc..d6ae199 100644
--- a/lib/gen_cmd.py
+++ b/lib/gen_cmd.py
@@ -96,21 +96,23 @@
     out_buf = ""
     if return_stderr:
         for line in sub_proc.stderr:
-            err_buf += line
+            try:
+                err_buf += line
+            except TypeError:
+                line = line.decode("utf-8")
+                err_buf += line
             if not print_output:
                 continue
-            if robot_env:
-                grp.rprint(line)
-            else:
-                sys.stdout.write(line)
+            gp.gp_print(line)
     for line in sub_proc.stdout:
-        out_buf += line
+        try:
+            out_buf += line
+        except TypeError:
+            line = line.decode("utf-8")
+            out_buf += line
         if not print_output:
             continue
-        if robot_env:
-            grp.rprint(line)
-        else:
-            sys.stdout.write(line)
+        gp.gp_print(line)
     if print_output and not robot_env:
         sys.stdout.flush()
     sub_proc.communicate()
@@ -417,12 +419,20 @@
         try:
             if return_stderr:
                 for line in sub_proc.stderr:
-                    err_buf += line
+                    try:
+                        err_buf += line
+                    except TypeError:
+                        line = line.decode("utf-8")
+                        err_buf += line
                     if not print_output:
                         continue
                     func_stdout += line
             for line in sub_proc.stdout:
-                out_buf += line
+                try:
+                    out_buf += line
+                except TypeError:
+                    line = line.decode("utf-8")
+                    out_buf += line
                 if not print_output:
                     continue
                 func_stdout += line