STORM-352: fix logic for writing offsets to ZooKeeper

Should be self-explanatory from the diff.