optimize encoding speed