added frame encoding