Created the method to encode the Pieces