add a benchmark and speed up RGB encoding