b2d: protect against empty clip region
minor code cleanup
image saving: fix storing byte objects