Apply a modified version of
7c76bbb0c989cb5e5e552f28668a985243438cab
from master; when we push an encoded frame's data to disk because we
can't write it yet, the idea i to set encoded in the QueueItem to 0
to say that the data has already been pushed to disk.
This was not working because we were resetting encoded in a copy of the QueueItem,
and hence not affecting the QueueItem held in _queue.
This meant that the same frame could be pushed to disk several times.
Use the iterator instead of a copy so that the QueueItem in the list
is modified.