simplified image i/o code