fix a bit in writeSprite