Added asynchronous callback function.
Added switch for JPEG or PNG compression.