For when my contact had no photo, I changed the SetPhoto code in ContactsUtils
SetData("vnd.android.cursor.item/photo", v, Id, True)
to
SetData("vnd.android.cursor.item/photo", v, Id, False)
I then called Setphoto in my own code with
cu.SetPhoto(k.Id, b, False)
which then worked for me, so it might be worth trying.
Good luck.