made changes to allow jpegs as source