import pickle


def save_pickled_data(data, file_path):
    """Saves data to file_path. Tries to be python2/3 compatible
    
    Args:
        data (any): Data to be saved
        file_path (String): Output filepath
    
    Return:
        See pickle.dump return
    """
    with open(file_path, "wb") as f:
        try:
            # Python3
            return pickle.dump(data,
                               f,
                               protocol=2,
                               fix_imports=True)
        except TypeError:
            # Python2
            return pickle.dump(data,
                               f,
                               protocol=2)