add overlay processing in encoding