Split out `save_output_image_if_necessary` into its own file so the code
can be shared by servoshell on the desktop and ohos.
Additionally, hook it up to the loop in OHOS and have OHOS allow
exiting.
Testing: Manual testing on ohos and desktop.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>