Update writePixel rather than create a new function