tool functions (matchWM, pad) now return the image
fixed hack in strip_header