How do we get images of galaxies? First of all a very basic question upon which my main question is based. "Are the pictures of milkyway galaxy we see on books/mags are real ? ". If they are real then my question is, how we have taken that picture ? I mean, suppose you have to take a picture of a building, so you have to be out side of that building. In the same way for taking the picture of a galaxy you have to be outside of it. So if we have taken a picture of our galaxy, I assume we have to travel atleast 100,000 lightyears, which would take a lot of time. So how is  it possible ??
 A: It depends on what you mean by "real". Let's start with the Andromeda galaxy, which is easily visible with the unaided eye from the Northern hemisphere (and probably from a large part of the Southern hemisphere, too), but it does not look anything like what you are used seeing in photographs. It looks like a small, pale cloud in a dark patch of the sky and that's just the most luminous part of the core that is actually visible to humans. This, on the other hand, is a composite of the Moon and Andromeda as they would appear in the night sky if the galaxy was thousands of times more luminous than it is (and even that's a lie because the Moon is never anywhere close to Andromeda, as far as I know): 

As you can see, the enormous difference in surface luminosity between solar system objects like the Moon and galaxies "lie" to us about their actual appearance. Or, if you want, you could say that the long exposure pictures we take with large telescopes and that are usually post-processed are the kinds of visual "lies" that are trying to appeal to our sense for beauty. 
A more positive way of saying these things is that telescopes and microscopes and particle accelerators and all the other tools of science are technological extensions of our senses that let us see nature in wavelengths and at scales and in ways that our natural senses do not cover. 
Now let's come to the case of the milky way. We do not have an actual visual observation of it since that would require a very long journey trough space, just as you say. What we do have are observations in many different directions that are trying to estimate the density and distance of the matter that lies in that direction. This is similar to what a CT-scanner or an MRI machine are doing to reconstruct the three dimensional structure of our body. In case of the milky way that reconstruction is difficult and error prone. One could say that our current milky-way CT-scans are of very poor quality, if you like. They are barely good enough to determine the overall structure of the galaxy.
If you want to see what some of the data on which the better artistic drawings of the milky way are based, look at e.g. http://mnras.oxfordjournals.org/content/450/4/4150.full?keytype=ref&ijkey=tjeJAezGAmgdXzc ("Tracing the Galactic spiral structure with embedded clusters", D. Camargo, C. Bonatto and E. Bica, MNRAS Volume 450, Issue 4Pp. 4150-4160).
Now, if you apply what you know about Andromeda, that from the outside it looks like a very thin wisp of nighttime cloud, then you may get the idea that probably among the best possible views on the milky way that a human can get is from our current position on Earth, where we are looking at its dense central region from up-close. In a really dark night with good viewing that's really a sight to behold! 
A: 
How do we get images of galaxies?

With cammeras and film, with or without a telescope that magnifies what one sees, as here:


NGC 4414, a typical spiral galaxy in the constellation Coma Berenices, is about 55,000 light-years in diameter and approximately 60 million light-years away from Earth .

You ask:

I mean, suppose you have to take a picture of a building, so you have to be out side of that building. 

This is right outside the building. Though a full stadium analogy is best. If you are in a helicopeter you get a complete picture. If you are in the stadium you can get some all round views. Knowing that stadiums  exist, you can reconstruct the stadium around you. Our galaxy is called the milky way, and has been reconstructed.

From Earth, the Milky Way appears as a band because its disk-shaped structure is viewed from within. Galileo Galilei first resolved the band of light into individual stars with his telescope in 1610. Until the early 1920s, most astronomers thought that the Milky Way contained all the stars in the Universe. Following the 1920 Great Debate between the astronomers Harlow Shapley and Heber Curtis,[24] observations by Edwin Hubble showed that the Milky Way is just one of many galaxies—now estimated to number as many as 200 billion galaxies in the observable universe

.......


As viewed from Earth, the visible region of the Milky Way's Galactic plane occupies an area of the sky that includes 30 constellations.[41] The center of the Galaxy lies in the direction of the constellation Sagittarius; it is here that the Milky Way is brightest. From Sagittarius, the hazy band of white light appears to pass around to the Galactic anticenter in Auriga. The band then continues the rest of the way around the sky, back to Sagittarius. The band divides the night sky into two roughly equal hemispheres

A: The images are taken by very very powerful telescopes, like Hubble and Kepler. The images are also taken by space stations and satellites in form of radio waves which are electromagnetic waves. So the images are not damaged since radio waves need no medium to travel/ But the images are taken in black and white, which can later be coloured according to their distance and chemical composition. The images are very accurate.
