Tools: Made imagestats more resistant to flag values