python3 fix: making a copy of dictionary for chaning during iteration