Encode chunks off the main thread.