1. As many others have done, switch to using SPI writebytes2() to send pixel data in bulk. This makes a significant difference on a Raspberry Pi Zero W.
2. Use PIL (Pillow) to convert the image into the correct 4-bit color using a custom palette. This dramatically speeds up conversion of the image, with the benefit of allow any kind of input image. PIL will dither quantize/dither the colors as needed.
3. Minor formatting changes to add/remove whitespace