Refactoring and added support for jpg images.

Need to find a way other than the binary file extension to determine
its type.