Interplay of structural and magnetic nanoscale phase separation in layered cobaltites