API for various compression codecs

First draft of API.
@trustin and @normanmaurer please review it.
This must be removed as the promise is already passed to finishEncode and so notified.