Refactored functions that copy sdout and stderr to strings to use a callback.
am: 07ac8554b4

Change-Id: Ia98cd1f03e6d5fdf88297211f263835243790068