More robust method for creating the image directory

For whatever reason, tp_get_img_dir stopped returning the expected value on one site I run. This patch fixes the issue and seems like a more robust approach to creating the necessary directory because it avoids using two distinct code paths to create related file paths.