Dynamics and phase transitions of Josephson junctions with dissipation due to quasiparticle tunneling