One of the themes of the second half of Sefer Bereishis, including the end of our Parsha, is dreams and their interpretations. The Torah tells us that Yosef listened to and correctly interpreted the dreams of Paroh's butler and baker (בראשית מ':ה'-כ"ב). The Gemara in Berachos (.דף נ"ו) tells a story of a dream interpreter named Bar Hadaya. The interpretations he presented would be favorable depending upon how much the inquirer paid. Two famous people who got involved with him were Abayei and Rava. Abayei would pay Bar Hadaya well and in return he received a favorable interpretation. Rava, on the other hand, did not pay Bar Hadaya and he received unfavorable interpretations. Sometimes, the very same dream was interpreted differently for Rava than for Abayei, as the Gemara (שם) states. After Rava began to experience some suffering, he understood what he was doing wrong, and he went and paid Bar Hadaya in full, and continued to have his dreams interpreted. Now that Rava was paying, his fortunes became good and his dreams were interpreted in a favorable light. The Gemara (שם) says that Rava concluded from this that the importance of a dream depends upon how it is interpreted, and that anything bad which results is really because of the interpretation, not the dream.
The Gemara earlier (שם דף נ"ה:) actually derives this point from the events in our Parsha. When Yosef interpreted the butler's dream, he interpreted it in a positive way. The baker saw this and hoped that his would be interpreted that way as well. However, his dream was interpreted in a negative way and he suffered for it; the Gemara (שם) thus says that the value of the dream is determined by its interpretation, meaning that the events would not necessarily have turned out the way they did except that Yosef had interpreted the dreams that way. The Yalkut Me'am Loez points out that many Chachomim have tried to understand the logic of this. Why should something happen or not happen just because someone interpreted a dream in a certain way? If a dream is meaningless, how can the interpretation give it any validity? And if a dream contains a sign from Hashem, how can the interpretation affect it? He concludes that this simply is another mystery of the world which we cannot understand.