speed up file/image performance

this eliminates a LOT of unnecessary db queries