An X-ray machine is essentially a camera. Instead of visible light, however, it uses X-rays to expose the film.
X-rays are like light in that they are electromagnetic waves, but they are more energetic so they can penetrate through many materials to varying degrees. When the X-rays hit the film, they expose it just as light would.
Since bone, fat, muscle, tumors and other masses all absorb X-rays at different levels, the image on the film lets you see different (distinct) structures inside the body because of the different levels of exposure on the film.
The reason you see only bones or tumors is because they are solid and therefore X-ray light rays can not pass through.
You can see the example in the X-ray picture.