Clean image routines in utils. Also improve thumb file names.