write img to file then send it. writing img to stdout doesn't seem to work