add debug.Printf
fix handling broken image file