Make sure the current history is written before pasting some others.

This fix the following issue:
1. open an image on darkroom
2. apply some iop
3. copy and paste some iop from another image

At this stage the changes done in 2 are lost. This commit fix this issue.