Q:

How to make a camera survive in (near) space? 

I'm working on project for a high altitude camera suspended from a weather balloon in order to approximately simulate spaceflight.  I'm wondering how can I make a camera survive and continue to operate?  
For the current tests, it needs to work at altitudes of at least 30-40 km. 

A:

I've used a stock GoPro on a high altitude balloon that made it to 40 km, it recorded the whole way up and down (on external power).  So depending on your mass and financial budget you could use this camera. 
At the altitude you're working at the most likely problem you'll have would be the camera over heating due to the lack of air reducing its ability to cool itself.  This could be solved by over engineering any heat sinks, mounting a large block of aluminium to back of a raspberry pi camera for example.