Optimizing the pixel drawing code and timer ISR