Optimal programming with voltage-controlled temperature profile to reduce SET state distribution dispersion in PCM