Updated writePixel to improve write times.