Improvement of spatial resolution in a Timepix based CdTe photon counting detector using ToT method