First, as cracauer already said: Before you can fix it, you need to diagnose it. Do you know for sure that the problem is memory pressure? Read up on how the OOM killer works. You said you "have 16GB in the system and memory was at like 8GB", which makes me think that memory pressure might not be the problem. What exactly are the error messages? If I remember right, the OOM killer leaves log entries in dmesg or /var/log/messages, so you should be able to see if that's the problem.
Second, assuming that memory pressure is actually the problem, there are two ways to fix it. One is to create more memory. Either remove other processes that use memory, or install more physical memory (or make your program distributed), or add more swapspace. The latter is the easiest, but be warned that a program that has to swap all the time will run amazingly slow.
Third, the second way to fix the program is to make it use less memory. You say the program is in Python. That's a wonderful programming language, but it can be quite inefficient using CPU and particularly memory. Think about the data structures you're using. In particular, if your data is parsed into many objects which then each contain small data types (integers, floats, strings), and the objects kept in structures such a lists and trees, memory usage can easily 10x more than in other programming systems. You may want to look at using NumPy and SciPy arrays or Series/Dataframes instead, and other space-efficient data structures.