remove most of the 'bashisms' in the script, improve quoting, escaping and make more consistent regarding references to variable names
add output variables for digests and if image was refreshed or not