Changed implementation to work for all scenarios for encoding filename of resized images