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 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.
Here are some interesting links: