BUG #14214: Fixes issues when tracing write-image.

Addresses a few issues with Python tracing of write-image and other UI actions.
The order of the traced events ended up being incorrect due to incorrect
flushing on the queue. Fixed that.

Change-Id: I8e90c8b7621530c04cecb43cc501c81db53248e4
Merge topic '14214_fix_tracing_issues' into next

fda6f14 BUG #14214: Fixes issues when tracing write-image.