Which encyclical talks about the Mass as a sacrifice? I am interested to know if there are any encyclicals which specifically compare the sacrifice of the Mass with the Temple sacrifices of the old Testament, wherein Jesus himself takes the place of the sacrificial animal.

I know this is standard Catholic Theology, and I know we Catholics talk freely about the sacrifice of the Mass (certainly the words of the liturgy points us in that direction).  But I want to read an actual encyclical where the link between Jesus and the animal sacrificed in the Temple of old is made explicitly clear.  The catechism of course mentions the Mass as a sacrifice, but it doesn't get into the exact details of what corresponds with what.
Chapter 1 of the 22nd Session of the Council of Trent directly states that the sacrifice of Christ on the Cross, which is re-presented in the Mass, replaces the Levitical priesthood (that is the sacrifices of the Old Testament in the temple) as well as "various types of sacrifices, during the period of nature, and of the law," so not just the Jewish temple sacrifices, but also, e.g. the sacrifice of Melchizedek is a prefigurement of the Sacrifice of Christ in the Mass.


  CHAPTER I.
  
  On the institution of the most holy Sacrifice of the Mass.
  
  Forasmuch as, under the former Testament, according to the testimony
  of the Apostle Paul, there was no perfection, because of the weakness
  of the Levitical priesthood; there was need, God, the Father of
  mercies, so ordaining, that another priest should rise, according to
  the order of Melchisedech, our Lord Jesus Christ, who might
  consummate, and lead to what is perfect, as many as were to be
  sanctified. He, therefore, our God and Lord, though He was about to
  offer Himself once on the altar of the cross unto God the Father, by
  means of his death, there to operate an eternal redemption;
  nevertheless, because that His priesthood was not to be extinguished
  by His death, in the last supper, on the night in which He was
  betrayed,--that He might leave, to His own beloved Spouse the Church,
  a visible sacrifice, such as the nature of man requires, whereby that
  bloody sacrifice, once to be accomplished on the cross, might be
  represented, and the memory thereof remain even unto the end of the
  world, and its salutary virtue be applied to the remission of those
  sins which we daily commit,--declaring Himself constituted a priest
  for ever, according to the order of Melchisedech, He offered up to God
  the Father His own body and blood under the species of bread and wine;
  and, under the symbols of those same things, He delivered (His own
  body and blood) to be received by His apostles, whom He then
  constituted priests of the New Testament; and by those words, Do this
  in commemoration of me, He commanded them and their successors in the
  priesthood, to offer (them); even as the Catholic Church has always
  understood and taught.
  
  For, having celebrated the ancient Passover, which the multitude of
  the children of Israel immolated in memory of their going out of
  Egypt, He instituted the new Passover, (to wit) Himself to be
  immolated, under visible signs, by the Church through (the ministry
  of) priests, in memory of His own passage from this world unto the
  Father, when by the effusion of His own blood He redeemed us, and
  delivered us from the power of darkness, and translated us into his
  kingdom. And this is indeed that clean oblation, which cannot be
  defiled by any unworthiness, or malice of those that offer (it); which
  the Lord foretold by Malachias was to be offered in every place, clean
  to his name, which was to be great amongst the Gentiles; and which the
  apostle Paul, writing to the Corinthians, has not obscurely indicated,
  when he says, that they who are defiled by the participation of the
  table of devils, cannot be partakers of the table of the Lord; by the
  table, meaning in both places the altar. This, in fine, is that
  oblation which was prefigured by various types of sacrifices, during
  the period of nature, and of the law; in as much as it comprises all
  the good things signified by those sacrifices, as being the
  consummation and perfection of them all.


You can also refer to the Encylical, Mediator Dei of Pope Pius XII, especially at numbers 16-20 (of which the following is a part):


  
  Thus we observe that when God institutes the Old Law, He makes provision besides for sacred rites, and determines in exact detail the
  rules to be observed by His people in rendering Him the worship He
  ordains. To this end He established various kinds of sacrifice and
  designated the ceremonies with which they were to be offered to Him.
  His enactments on all matters relating to the Ark of the Covenant, the
  Temple and the holy days are minute and clear. He established a
  sacerdotal tribe with its high priest, selected and described the
  vestments with which the sacred ministers were to be clothed, and
  every function in any way pertaining to divine worship.[11] Yet this
  was nothing more than a faint foreshadowing[12] of the worship which
  the High Priest of the New Testament was to render to the Father in
  heaven.
  No sooner, in fact, "is the Word made flesh"[13] than he shows Himself to the world vested with a priestly office, making to the
  Eternal Father an act of submission which will continue
  uninterruptedly as long as He lives: "When He cometh into the world he
  saith. . . 'behold I come . . . to do Thy Will."[14] This act He was
  to consummate admirably in the bloody Sacrifice of the Cross: "It is
  in this will we are sanctified by the oblation of the Body of Jesus
  Christ once."[15] He plans His active life among men with no other
  purpose in view. As a child He is presented to the Lord in the Temple.
  To the Temple He returns as a grown boy, and often afterwards to
  instruct the people and to pray. He fasts for forty days before
  beginning His public ministry. His counsel and example summon all to
  prayer, daily and at night as well. As Teacher of the truth He
  "enlighteneth every man"[16] to the end that mortals may duly
  acknowledge the immortal God, "not withdrawing unto perdition, but
  faithful to the saving of the soul."[17] As Shepherd He watches over
  His flock, leads it to life-giving pasture, lays down a law that none
  shall wander from His side, off the straight path He has pointed out,
  and that all shall lead holy lives imbued with His spirit and moved by
  His active aid. At the Last Supper He celebrates a new Pasch with
  solemn rite and ceremonial, and provides for its continuance through
  the divine institution of the Eucharist. On the morrow, lifted up
  between heaven and earth, He offers the saving sacrifice of His life,
  and pours forth, as it were, from His pierced Heart the sacraments
  destined to impart the treasures of redemption to the souls of men.
  All this He does with but a single aim: the glory of His Father and
  man's ever greater sanctification.
  


Pope Pius XII draws extensively on the Letter of St. Paul to the Hebrews in discussing the Mass as sacrifice.

I would note that it's somewhat broader than how you put it. Christ doesn't exactly take the place of the animal sacrificed on the altar of the Temple, rather the animal sacrificed on the altar of the temple is a prefigurement of Christ's sacrifice on the Cross (and in the Mass), so His sacrifice is something more.