Ensure that image output stream errors are handled.

Change-Id: I70bb928230a7b58d2557e67ca8cd6a5a2b764edf