forked and modified version of https://github.com/Squeegy/fleximage shoe-horned into working in Rails 3 (for the bits we need)