added jpegrescan (under public domain)
restructured image thumbnailing code, added optimize features