Characterization, calibration, and optimization of time-resolved CMOS single-photon avalanche diode image sensor