Updated API to support image formats PNG and JPEG