The repeal of a law, or its expiration by virtue of any provision contained therein, shall not affect any offense committed, or penalty or punishment incurred, before the repeal took effect, or the law expired, save only that the proceedings thereafter had shall conform as far as practicable to the laws in force at the time such proceedings take place, unless otherwise specially provided; and that if any penalty or punishment be mitigated by the new law, such new law may, with the consent of the party affected thereby, be applied to any judgment pronounced after it has taken effect.