Simulation of instabilities in plasticity and thermo-plasticity